//
//  FCAlamView.m
//  OilWear
//
//  Created by jjkj on 17/7/10.
//  Copyright © 2017年 jjkj. All rights reserved.
//

#import "FCAlamView.h"
#import "UIButton+RoundedCorner.h"
#import "HomeCarModel.h"

@implementation FCAlamView

- (void)awakeFromNib {
    [super awakeFromNib];
    //切圆角
    [self.oilWearAlarm addRounedCornerWithRadius:10];
    [self.breakenAlarm addRounedCornerWithRadius:10];
    [self.overSpeedAlarm addRounedCornerWithRadius:10];
    [self.AddOilAlarm addRounedCornerWithRadius:10];

}
-(instancetype)initWithCoder:(NSCoder *)aDecoder {
    self = [super initWithCoder:aDecoder];
    if (self) {
        [self setUp];
    }
    return  self;
}
- (void)setUp {
    [[NSBundle mainBundle] loadNibNamed:@"FCAlamView" owner:self options:nil];
    [self addSubview:self.view];
    
    self.view.frame = self.bounds;
    
}

- (IBAction)alarmActionHandle:(UIButton *)sender {
    
    if (self.exchangeAlarmBlock) {
        self.exchangeAlarmBlock(sender.tag);
    }
    NSLog(@"告警详情");
}
- (void)setObjectWith:(HomeCarModel *)homeCarModel {

//    [self.oilWearAlarm setTitle:homeCarModel.iollossError forState:(UIControlStateNormal)];
//    [self.oilWearAlarm setTitle:homeCarModel.iollossError forState:(UIControlStateHighlighted)];
//    
//    [self.breakenAlarm setTitle:homeCarModel.faultError forState:(UIControlStateNormal)];
//    [self.breakenAlarm setTitle:homeCarModel.faultError forState:(UIControlStateHighlighted)];
//    
//    [self.overSpeedAlarm setTitle:homeCarModel.speedingError forState:(UIControlStateNormal)];
//    [self.overSpeedAlarm setTitle:homeCarModel.speedingError forState:(UIControlStateHighlighted)];
//    
//    [self.AddOilAlarm setTitle:homeCarModel.addiolError forState:(UIControlStateNormal)];
//    [self.AddOilAlarm setTitle:homeCarModel.addiolError forState:(UIControlStateHighlighted)];
    NSString *oilError = [NSString stringWithFormat:@"油耗报警\n %@次",homeCarModel.iollossError];
    self.oilWearAlarm.titleLabel.numberOfLines = 0;
    self.oilWearAlarm.titleLabel.textAlignment = UITextAlignmentCenter;
    self.breakenAlarm.titleLabel.numberOfLines = 0;
    self.breakenAlarm.titleLabel.textAlignment = UITextAlignmentCenter;
    self.overSpeedAlarm.titleLabel.numberOfLines = 0;
    self.overSpeedAlarm.titleLabel.textAlignment = UITextAlignmentCenter;
    self.AddOilAlarm.titleLabel.numberOfLines = 0;
    self.AddOilAlarm.titleLabel.textAlignment = UITextAlignmentCenter;
    
    [self.oilWearAlarm setTitle:oilError forState:(UIControlStateNormal)];
    [self.oilWearAlarm setTitle:oilError forState:(UIControlStateHighlighted)];
    
    [self.breakenAlarm setTitle:[NSString stringWithFormat:@"故障报警\n%@次",homeCarModel.faultError] forState:(UIControlStateNormal)];
    [self.breakenAlarm setTitle:[NSString stringWithFormat:@"故障报警\n%@次",homeCarModel.faultError]  forState:(UIControlStateHighlighted)];
    
    [self.overSpeedAlarm setTitle:[NSString stringWithFormat:@"超速报警\n%@次",homeCarModel.speedingError]  forState:(UIControlStateNormal)];
    [self.overSpeedAlarm setTitle:[NSString stringWithFormat:@"超速报警\n%@次",homeCarModel.speedingError]  forState:(UIControlStateHighlighted)];
    
    [self.AddOilAlarm setTitle:[NSString stringWithFormat:@"加油报警\n%@次",homeCarModel.addiolError]  forState:(UIControlStateNormal)];
    [self.AddOilAlarm setTitle:[NSString stringWithFormat:@"加油报警\n%@次",homeCarModel.addiolError] forState:(UIControlStateHighlighted)];
    
}
@end
